#define DEBUG
#include <cstdio>
#define MAXN 300000
#define MAXM 300000

using namespace std;

int min(int a, int b) {
  return a<b ? a : b;
}

int max(int a, int b) {
  return a>b ? a : b;
}

class Set {
public:
  int fa[MAXN+1], rank[MAXN+1], v[MAXN+1], time, opt[MAXN+1][3];

  void init(int n) {
    for (int i=1; i<=n; i++) {
      fa[i] = i, rank[i] = 1, v[i]=0;
    }
    time=0;
  }

  int getFa(int o, int &x) {
    if (fa[o]!=o) {
      x = (x+v[o])%2;
      return getFa(fa[o], x);
    } else {
      return o;
    }
  }

  bool merge(int a, int b) {
    int x=0, y=0;
    a = getFa(a, x), b = getFa(b, y);
    if (a==b && x!=y) {
      return true;
    } else if (a!=b) {
      time++;
      if (rank[a]<rank[b]) {
	opt[time][0] = a;
	v[a] = (x+y+1)%2;
	fa[a] = b;
	opt[time][1] = b;
	opt[time][2] = rank[b];
      }  else {
	opt[time][0] = b;
	v[b] = (x+y+1)%2;
	fa[b] = a;
	opt[time][1] = a;
	opt[time][2] = rank[a];
	if (rank[a]==rank[b]) {
	  rank[a]++;
	}
      }
      return true;
    } else {
      return false;
    }
  }

  void pushBack(int o) {
    for (; time>o; time--) {
      fa[opt[time][0]] = opt[time][0];
      v[opt[time][0]] = 0;
      rank[opt[time][1]] = opt[time][2];
    }
  }
};

class SegmentTree {
public:
  int ind[4*MAXM+1], a[8*MAXM+1], b[8*MAXM+1], link[8*MAXM+1], m, n;
  Set set;

  void init(int n) {
    set.init(n);
    this->n = n;
  }

  void add(int o, int l, int r, int tl, int tr, int a, int b) {
    if (l==tl && r==tr) {
      m++;
      this->a[m]=a, this->b[m]=b;
      link[m] = ind[o];
      ind[o] = m;
    } else {
      int mid=(l+r)/2;
      if (tl<=mid && tr>=l) {
	add(o*2, l, mid, max(tl, l), min(tr, mid), a, b);
      }
      if (tl<=r && tr>mid) {
	add(o*2+1, mid+1, r, max(tl, mid+1), min(tr, r), a, b);
      }
    }
  }

  void solve(int o, int l, int r, bool flag) {
    int time=set.time;
    for (int i=ind[o]; i && flag; i=link[i]) {
      flag = set.merge(a[i], b[i]);
    }
    if (l==r) {
      printf(flag ? "YES\n" : "NO\n");
    } else {
      int mid=(l+r)/2;
      solve(o*2, l, mid, flag);
      solve(o*2+1, mid+1, r, flag);
    }
    set.pushBack(time);
  }
};

int main() {
  freopen("graph.in", "r", stdin);
  freopen("graph.out", "w", stdout);

  static SegmentTree sgt;
  static int a[MAXM+1], b[MAXM+1], id[MAXM+1];
  static bool book[MAXM+1];
  int n, m, cnt=0;
  scanf("%d %d", &n, &m);
  sgt.init(n);
  for (int i=1; i<=m; i++) {
    int type;
    scanf("%d", &type);
    if (type) {
      cnt++;
      scanf("%d %d", a+cnt, b+cnt);
      a[cnt]++, b[cnt]++, id[cnt]=i, book[cnt]=false;  
    } else {
      int t;
      scanf("%d", &t);
      t++;
      book[t] = true;
      sgt.add(1, 1, m, id[t], i-1, a[t], b[t]);
    }
  }
  for (int i=1; i<=cnt; i++) {
    if (!book[i]) {
      sgt.add(1, 1, m, id[i], m, a[i], b[i]);
    }
  }

  sgt.solve(1, 1, m, true);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
